<?php 
session_start(); 
require_once('include/connect.inc.php'); 
if($_SESSION['sess_id'] <> session_id()){
?>
 <SCRIPT LANGUAGE="JavaScript">
			alert("กรุณาเข้าสู่ระบบให้ถูกต้องตามขั้นตอน...!");
			location="login.php";
</script>
<?php }?>
<?php
if($_REQUEST['teacher_id'] != "") //ถ้า ค่า teacher_id ไม่เท่ากับค่าว่างเปล่า
{
$del_id = $_REQUEST['teacher_id'];
$sql_del = "delete from tb_teacher where r_teacher_id = '$teacher_id';";
mysql_query($sql_del) or die(mysql_error());
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Model Test Program</title>
<link rel="stylesheet" type="text/css" href="template/template_style_wood.css">
</head>

<body>
<div id="menu"><div><img src="../images/icon-m.png" /></div>
<div id="menulinks">
		<a class="active" href="person.php">จัดการบุคลากร</a>
		<a  href="problem/admin_resive.php">ตรวจสอบความคิดเห็น</a>
        <a  href="new/manage_news.php">ประกาศข่าวสาร</a>
        <a href="logout.php">ออกจากระบบ</a>
		</div></div>
        
      <div id="p3">    
<div id="header"></div>
<div id="page"><div id="p1">คุณ<?php echo"$admin_name";?><hr />
    <form name="form1" id="form1" method="post" action="person_show_tea.php">
	<table  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <th align="left">จัดการข้อมูลผู้จัดการข้อสอบ</th>
        <th align="right"><a href="person_insert_tea.php"><img src="images/add.png" border="0" /></a></th>
      </tr>
    </table>
	 <table border="0" id="table"  summary="2007 Major IT Companies Profit">
      <tr>
        <th align="center">ลำดับ</th>
        <th align="center">รหัสประจำตัว</th>
        <th align="center">รหัสผ่าน</th>
        <th align="center">ชื่อ - สกุล</th>
        <th align="center">คณะ</th>
        <th align="center">สาขาวิชา</th>
        <th align="center">e-mail</th>
        <th align="center">เบอร์โทร</th>
        <th align="center">ลบ</th>
        <th align="center">แก้ไข</th>
      </tr>
	<?php
	$query = query("SELECT * FROM tb_teacher 
			Inner Join tb_fac ON tb_fac.fac_id = tb_teacher.fac_id
			Inner Join tb_major ON tb_major.major_id = tb_teacher.major_id");
		  $count=1;
				while ($rs = fetch_array($query)) {
					$teacher_id 				= $rs['r_teacher_id'];
					$teacher_password = $rs['teacher_password'];
					$teacher_name 		= $rs['teacher_fname']." ".$rs['teacher_lname'];
					$fac_name 				= $rs['fac_name'];
					$major_name 			= $rs['major_name'];
					$teacher_email 		= $rs['teacher_email'];
					$teacher_phone 		= $rs['teacher_phone'];
		?>
      <tr>
        <td align="center"><?php echo $count;echo ".";?></td>
        <td ><?php echo $teacher_id;?></td>
        <td ><?php echo $teacher_password;?></td>
        <td><?php echo $teacher_name; ?></td>
        <td ><?php echo $fac_name;?></td>
        <td ><?php echo $major_name;?></td>
        <td ><?php echo $teacher_email;?></td>
        <td ><?php echo $teacher_phone;?></td>
        <td> 
	   <script language="JavaScript">
		function Conf<?=$rs["r_teacher_id"]; ?>(object) {
		if (confirm("ยืนยันการลบข้อมูล") ==true) {
		return true;
		}
		return false;
		}
          </script>
	<a href="person_show_tea.php?teacher_id=<?=$rs["r_teacher_id"];?>"
      onclick="return Conf<?=$rs["r_teacher_id"]; ?>(this)"> <img src="images/delete1.png" border="0" /></a>
     </td>
        <td align="center"><a href="person_edit_tea.php?teacher_id=<?=$rs["r_teacher_id"];?>"><img src="images/edit.png" border="0" /></a></td>
      </tr>  
      <?php $count++; }?>  
    </table>
  </form><br /><br /><br /><br />
    </div>
    </div>
<div id="footer"></div>
</div>
</body>
</html>